<template>
    <div class="management-merchant views-container">
        <div class="wlm-table">
          <div class="wlm-table-header">
            <el-form  size="small" label-width="80px" class="retail-form" label-position="right">
                <el-form-item class="filter">
                    <el-form-item label="入账时间:">
                           <el-date-picker
                                style="width:360px;margin-right:0;"
                                v-model="tableFormatData.merchantaccount.files.time"
                                :picker-options="pickerOptions"
                                value-format="timestamp"
                                type="datetimerange"
                                range-separator="至"
                                start-placeholder="开始日期"
                                end-placeholder="结束日期"
                                :default-time="['00:00:00', '23:59:59']"
                            >
                            </el-date-picker>
                    </el-form-item>
                      <el-form-item label="商户:">
                            <el-select v-model="tableFormatData.merchantaccount.files.bus_id" placeholder="请选择">
                                <el-option
                                v-for="item in getBustAlldata"
                                :key="item.id"
                                :label="item.name"
                                :value="item.id">
                                </el-option>
                            </el-select>
                    </el-form-item>
                    <el-form-item label="所属代理:">
                          <el-select v-model="tableFormatData.merchantaccount.files.aid" placeholder="请选择">
                                <el-option
                                v-for="item in getAgentAlldata"
                                :key="item.id"
                                :label="item.agentname"
                                :value="item.id">
                                </el-option>
                            </el-select>
                    </el-form-item>
                </el-form-item>
                 <el-form-item label="" class="filter-btns">
                    <el-button v-waves type="primary" @click="filesSerch">筛选</el-button>
                    <el-button type="text" @click="filesEmpty">清空筛选条件</el-button>
                </el-form-item>
            </el-form>
     </div>
             <div class="wlm-table-content">
            <el-table  style="width: 100%" :ref="tableFormatData.merchantaccount.key" :data="tableFormatData.merchantaccount.tableData" @selection-change="handleSelectionChange">
                  <el-table-column label="结算时间">
                       <template slot-scope="scope">
                           <span>{{scope.row.create_time}}</span>
                       </template>
                  </el-table-column>
                  <el-table-column label="商家账户">
                       <template slot-scope="scope">
                           <span>{{scope.row.bus.name}}</span>
                       </template>
                  </el-table-column>
                   <el-table-column label="类型">
                       <template slot-scope="scope">
                           <span>{{scope.row.type}}</span>
                       </template>
                  </el-table-column>
                   <el-table-column label="收入支出">
                       <template slot-scope="scope">
                           <span v-if="scope.row.bus_money>0" style="color:#67C23A;">+{{scope.row.bus_money}}</span>
                            <span v-else style="color:red;">-{{scope.row.bus_money}}</span>
                       </template>
                  </el-table-column>
                   <el-table-column label="账户余额">
                       <template slot-scope="scope">
                           <span>{{scope.row.bus.money}}</span>
                       </template>
                  </el-table-column>
                   <!-- <el-table-column label="详情/备注">
                       <template slot-scope="scope">
                              <router-link
                                class="wlm-text"
                                tag="span"
                                :to="{path:'/orders/ordersVerificationManagementDetail', query:{
                                order_id:scope.row.order_id,
                               }}">
                                <el-button type="text">查看详情</el-button>
                                </router-link>
                       </template>
                  </el-table-column> -->
            </el-table>
              <div class="pagination-content flex-row flex-justify-e flex-align-c">
                   <el-pagination :disabled="!hasTableData" @size-change="listPageChange" @current-change="listPageChange" :current-page.sync="tableFormatData.merchantaccount.pagination.page" :page-sizes="tableFormatData.merchantaccount.pagination.pagesizes" :page-size.sync="tableFormatData.merchantaccount.pagination.list_rows" layout="total, sizes, prev, pager, next, jumper" :total="hasTableData?tableFormatData.merchantaccount.pagination.total : 0">
                </el-pagination>
                </div>
        </div>
        </div>
    </div>
</template>
<script>
import {getBusFinance,getAgentAll,getBustAll} from "@/api/cityagent";
import waves from '@/directive/waves' // Waves directive
import mixins from '@/mixins/mixins'
export default {
      mixins: [mixins.getters('Table')],
     name: 'merchantaccount',
       directives: {
    waves
  },
    data () {
        return {
            getBustAlldata:[],
            getAgentAlldata:[],
             tableFormatData: {
        current: 'merchantaccount',
        merchantaccount: {
          key: 'merchantaccount',
          api: {
            getList: getBusFinance,
            // delList: deleteAgentUser,
          },
          tableData: [],
        //   otherData:{
        //     money_type:''
        //   },
          files: {
            ids: [],
            time:[],
          },
          pagination: {
            page: 1,
            list_rows: 10,
            pagesizes: [10, 20, 50],
            total: 0
          }
        }
      }
        }
    },
    created () {
        this.$nextTick(()=>{
            this.getBustAllbtn()
            this.getAgentAllbtn()
        })
    },
    methods: {
            //请求商户数据
        getBustAllbtn(){
            getBustAll().then(res=>{
                if(res.data.code==1){
                    this.getBustAlldata = res.data.data
                }
            })
        },
        getAgentAllbtn(){
            getAgentAll().then(res=>{
                if(res.data.code==1){
                    this.getAgentAlldata = res.data.data
                }
            })
        }
    }
}
</script>